package com.ship.dispatch.controller;

import com.ship.common.core.web.domain.JsonResult;
import com.ship.dispatch.bean.treaShipNetwork.IhsShipBase;
import com.ship.dispatch.bean.treaShipNetwork.IhsShipBaseShipVo;
import com.ship.dispatch.service.ConShippingService;
import com.ship.dispatch.vo.PortInformationVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/freightCalculation")
@Api(value = "freightCalculation", tags = "运费测算前端控制器")
public class FreightCalculationController {
    @Autowired
    private ConShippingService conShippingService;

    @ApiOperation(value = "船舶名称筛选船舶租金信息")
    @GetMapping(value = {"/getIhsShipRentInfo/{name}", "/getIhsShipRentInfo"})
    public JsonResult getIhsShipRentInfo(@PathVariable(value = "name", required = false) String name) {
        List<IhsShipBase> ihsShipBases = conShippingService.getIhsShipBases(name);
        List<IhsShipBaseShipVo> ihsShipBaseVos = conShippingService.getIhsShipRentInfo(ihsShipBases);
        return JsonResult.success(ihsShipBaseVos);
    }

    @ApiOperation(value = "接收站带出该接收站下的历史平均船代费")
    @GetMapping(value = {"/getShipAgencyFee/{feeType}/{name}", "/getShipAgencyFee/{feeType}"})
    public JsonResult getShipAgencyFee(@PathVariable(value = "feeType") Integer feeType,@PathVariable(value = "name", required = false) String name) {
        List<PortInformationVo> portInformationVos = conShippingService.getShipAgencyFee(name,feeType);
        return JsonResult.success(portInformationVos);
    }
}
